﻿@model IEnumerable<wdsDeApp04.Models.FilmReview>

@{
    ViewBag.Title = "List";
}

<h2>List</h2>

@using (Html.BeginForm("List", "MyHome", FormMethod.Get))
{
    <span>电影名:</span>
    @Html.TextBox("movieName")
    <span>电影名:</span>
    @Html.TextBox("director")
    <input type="submit" value="查询" />
}

<p>
    @Html.ActionLink("写影评", "Add")
</p>
<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Id)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.MovieName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Director)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Score)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.MemberId)
        </th>
        <th>
            性别
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Comment)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.WatchDate)
        </th>
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Id)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.MovieName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Director)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Score)
            </td>

            <td>
                @{
                    var nameDic = ViewBag.nameDic as Dictionary<int, string>;
                    var name = nameDic.FirstOrDefault(u => u.Key == item.MemberId).Value;
                    @name
                }
            </td>
            <td>
                @{
                    var sexDic = ViewBag.sexDic as Dictionary<int, string>;
                    var sex = nameDic.FirstOrDefault(u => u.Key == item.MemberId).Value;
                    @sex
                }
            </td>

            <td>
                @Html.DisplayFor(modelItem => item.Comment)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.WatchDate)
            </td>
        </tr>
    }
</table>

